home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
c_lang
/
varinc.lzh
/
STDDEFS.H
< prev
next >
Wrap
Text File
|
1979-11-30
|
7KB
|
133 lines
/* HEADER FILE: STDDEFS.H */
/*****************************************************************************/
/* stddefs.h: standard defined symbols for general company use. The file */
/* stdio.h should be #included with this file if DEBUG macros or screen- */
/* control definitions will be used. */
/*****************************************************************************/
/* Symbols related to definition and use of shared data. Declarations of */
/* data with storage class static or external should begin with these */
/* shared-data modifiers: */
/* GLOBAL begins defining declarations for external data; data are */
/* shared by all functions that IMPORT the data. */
/* SEMIGLOBAL begins defining declarations for static external data; */
/* data are shared by functions in the same source file that IMPORT */
/* the data. */
/* IMPORT begins non-defining declarations of GLOBAL and SEMIGLOBAL */
/* data. A defining declaration allocates new, initialized storage. */
/* Non-defining declarations refer to data defined elsewhere, to */
/* allow examination or modification of those data. */
#define GLOBAL
#define SEMIGLOBAL static
#define IMPORT extern
/* Data types that are synonyms of other types. */
typedef unsigned char unchar; /* unsigned characters */
typedef unsigned short unshort; /* unsigned short integers */
typedef unsigned long unlong; /* unsigned long integers */
typedef char byte; /* byte: 1-byte number (0 to 127) */
typedef char bflag; /* bflag: 1-byte true/false flag */
typedef int flag; /* flag: int-sized true/false flag */
/* Constants for true or false data, to be used in conjunction */
/* with synonym types flag (int sized) and bflag (char sized). */
#ifndef YES /* If not already defined, then define YES, NO. */
#define YES 1
#define NO 0
#endif
/*****************************************************************************/
/* Symbols related to standard library function. */
/*****************************************************************************/
/* Status of SUCCEED or FAIL passed to exit(); aborts program. */
#define SUCCEED 0
#define FAIL 1
/* File handles (descriptor numbers) for standard files to be */
/* used with the low level I/O functions read() and write(). */
#define STDIN 0
#define STDOUT 1
#define STDERR 2
/*****************************************************************************/
/* DEBUG macros either produce debug output or disappear, depending upon */
/* whether or not DEBUG is defined. All take two arguments: a message */
/* to display and a value. The type of the value determines which macro */
/* will be correct to use. Pass a string that uniquely identifies this */
/* debug call as the first argument, id. */
/* */
/* SDBG(id, str) Shows string str and its length. */
/* LDBG(id, long) Shows long. */
/* IDBG(id, int) Shows int. */
/* UIDBG(id, unsigned_int) Shows unsigned int. */
/* CDBG(id, char) Shows ASCII and hex for a char. */
/* DDBG(id, double) Shows double. */
/* */
/* Note: #include <stdio.h> should precede this file. */
/*****************************************************************************/
#if defined(DEBUG) /* Is this a DEBUG compilation? */
/* Definitions for macro expansion prefix and suffix text. */
/* Arguments to CUR_MV control screen position of debug output. */
/* Replace "stderr" with "stdout" if debug output redirection is needed. */
#define DBG_BGN (CUR_SAVE, CUR_MV(24, 0), CLR_LINE, fprintf(stderr,
#define DBG_END ), getch(), CUR_REST)
#define SDBG(id, str) DBG_BGN "SDBG! %s = %-.50s, L = %d _\b", \
(id), (str), strlen(str) DBG_END
#define LDBG(id, lngv) DBG_BGN "LDBG! %s = %ld _\b", \
(id), (lngv) DBG_END
#define IDBG(id, intv) DBG_BGN "IDBG! %s = %d _\b", \
(id), (intv) DBG_END
#define UIDBG(id, uint) DBG_BGN "UIDBG! %s = %u _\b", \
(id), (uint) DBG_END
#define CDBG(id, chr) DBG_BGN "CDBG! %s = %c, (\\x%02x) _\b", \
(id), (chr), (chr) DBG_END
#define DDBG(id, dblv) DBG_BGN "DDBG! %s = %E _\b", \
(id), (dblv) DBG_END
#else /* Not in DEBUG mode; make DEBUG macros disappear */
/* by defining them with null expansions. */
#define SDBG(a, b)
#define LDBG(a, b)
#define IDBG(a, b)
#define UIDBG(a, b)
#define CDBG(a, b)
#define DDBG(a, b)
#endif
/*****************************************************************************/
/* Screen and Cursor-Control Commands: */
/* CUR_MV(r, c) Move cursor to row r (1-25), column c (1-80). */
/* CUR_UP(n) Move cursor up n lines (ignored if at top). */
/* CUR_DN(n) Move cursor down n lines (ignored if at bottom). */
/* CUR_RT(n) Move cursor right n spaces (ignored at right margin). */
/* CUR_LT(n) Move cursor left n spaces (ignored at left margin). */
/* CUR_SKIP Send newline. */
/* CUR_SAVE Save cursor position. */
/* CUR_REST Restore cursor position. */
/* CLR_SCRN Clear screen and move cursor to home. */
/* CLR_LINE Erase from cursor to end of line. */
/* CLR_EOS(r, c) Erase from row r, col c to screen end, leave cursor at r,c. */
/* BELL Ring bell once by sending control-g. */
/* */
/* NOTE: Definitions below are for ANSI.SYS terminal driver. */
/*****************************************************************************/
#define CUR_MV(row, col) fprintf(stderr, "\33[%d;%dH", row, col)
#define CUR_UP(num) fprintf(stderr, "\33[%dA", num)
#define CUR_DN(num) fprintf(stderr, "\33[%dB", num)
#define CUR_RT(num) fprintf(stderr, "\33[%dC", num)
#define CUR_LT(num) fprintf(stderr, "\33[%dD", num)
#define CUR_SKIP fputs("\n", stderr)
#define CUR_SAVE fputs("\33[s", stderr)
#define CUR_REST fputs("\33[u", stderr)
#define CLR_SCRN fputs("\33[2J", stderr)
#define CLR_LINE fputs("\33[K", stderr)
#define CLR_EOS(r, c) {byte i_; CUR_MV(r,c); \
for (i_=r; i_<=25; ++i_) CLR_LINE, CUR_DN(1); CUR_MV(r,c); }
#define BELL fputc('\7', stderr)